/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package au.csiro.nt.psdp.manager;

/**
 *
 * @author Administrator
 */
import org.acegisecurity.userdetails.UsernameNotFoundException;
import org.appfuse.service.UniversalManager;
import org.appfuse.service.UserExistsException;

import java.util.List;
import java.util.Set;

import au.csiro.nt.psdp.dao.UserDao;
import au.csiro.nt.psdp.model.User;
import au.csiro.nt.psdp.model.Role;


/**
 * Copy from Appfuse
 * Business Service Interface to handle communication between web and
 * persistence layer.
 *
 * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
 *  Modified by <a href="mailto:dan@getrolling.com">Dan Kibler </a>
 */
public interface UserManager extends UniversalManager
{

    public void setUserDao(UserDao userDao);

    /**
     * Retrieves a user by userId.  An exception is thrown if user not found
     *
     * @param userId the identifier for the user
     * @return User
     */
    public User getUser(String userId);

    /**
     * Finds a user by their username.
     * @param username the user's username used to login
     * @return User a populated user object
     * @throws org.acegisecurity.userdetails.UsernameNotFoundException
     *         exception thrown when user not found
     */
    public User getUserByUsername(String username) throws UsernameNotFoundException;

    /**
     * Retrieves a list of users, filtering with parameters on a user object
     * @param user parameters to filter on
     * @return List
     */
    public List getUsers(User user);
    public List getUsers(String userName);
    public List getInstructors();
    /**
     * Saves a user's information
     *
     * @param user the user's information
     * @throws org.appfuse.service.UserExistsException thrown when user already exists
     */
    public User saveUser(User user) throws UserExistsException;

    /**
     * Bulk create numberOfUsers amount of Users with the baseUsername plus a int suffix starting
     * from 1 to numberOfUsers.
     * @param baseUsername base username
     * @param numberOfUsers number of users to create
     * @return List of created users
     */
    public Set<User> bulkCreateUsers(String baseUsername, int numberOfUsers, String password, Set<Role> roles);

    /**
     * Bulk create numberOfUsers amount of Users with the baseUsername plus a int suffix starting
     * from start to numberOfUsers.
     * @param baseUsername base username
     * @param numberOfUsers number of users to create
     * @return List of created users
     */
    public Set<User> bulkCreateUsers(String baseUsername, int start, int numberOfUsers, String password, Set<Role> roles);

    public Set<User> bulkRemoveUsers(String baseName, int start, int end);

    /**
     * Bulk Save a list of user's
     *
     * @param users the list of user's to save
     * @throws org.appfuse.service.UserExistsException thrown when user already exists
     */
    public Set<User> saveUsers(List<User> users) throws UserExistsException;

    /**
     * Removes a user from the database by their userId
     *
     * @param userId the user's id
     */
    public void removeUser(String userId);

    public void removeUser(User user);
}
